/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details:
 * http://www.gnu.org/copyleft/lesser.html#TOC3
 */
package com.simplemonkey;


import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
import com.simplemonkey.appearance.SpacingAppearance;
import com.simplemonkey.layout.ILayoutData;
import com.simplemonkey.tooltip.IToolTip;
import com.simplemonkey.util.Dimension;


public interface IWidget
{

	public ILayoutData getLayoutData();
	
	public IContainer getParent();

	public SpacingAppearance getSpacingAppearance();
	
	public float getWorldX();

	public float getWorldY();

	public IWidget getWidget(float x, float y);

	public void updateMinSize();

	public Dimension getSize();
	
	public Dimension getMinSize();

	public void setParent(IContainer parent);

	public String getName();
	
	/**
	 * Tests if the position (in world coordinates) intersects this widget
	 * @param position
	 * @return 
	 */
	public boolean testCollision(Vector3f position);
	
	/**
	 * Get this widget's X position relative to its parent
	 * @param p
	 */
	public float getX();
	
	/**
	 * Get this widget's Y position relative to its parent
	 * @param p
	 */
	public float getY();
	public  float getWidth();
	public  float getHeight();
	
	/**
	 * Get this widget's position relative to its parent
	 * @param p
	 */
	public  Vector3f getPosition();
	
	/**
	 * Set this widget's position relative to its parent
	 * @param p
	 */
	public  void setPosition(Vector3f p);
	
	/**
	 * Set this widget's position relative to its parent
	 * @param p
	 */
	public void setPosition(float x, float y);
	
	/**
	 * Set this widget's X position relative to its parent
	 * @param p
	 */
	public  void setX(float x);
	
	/**
	 * Set this widget's Y position relative to its parent
	 * @param p
	 */
	public  void setY(float y);

	public  Dimension getMinContentSize();

	public  boolean isTraversable();	

	public  void layout();

	/**
	 * Set this widget's position relative to the world, not to its parent
	 * @param p
	 */
	public void setWorldPosition(float x, float y);
	
	
	public void addResizeListener(IResizeListener listener);
	
	public void removeResizeListener(IResizeListener listener);
	
	public void addMouseListener(IMouseListener listener);
	
	public void removeMouseListener(IMouseListener listener);
	
	public  void setSize(Dimension d);
	
	/**
	 * Checks if the widget is set to be visible or not. Doesn't check if the
	 * widget is actually drawn on screen.
	 * 
	 * @return true if the widget should be visible.
	 */
	public  boolean isVisible();
	
	/**
	 * Sets the visibility state of the widget. If set to false the widget will
	 * not be drawn and will not receive any events but takes its space (remains
	 * in the widget-tree). Also all child elements will not be drawn or receive
	 * any events.
	 * 
	 * @param visible True if the widget should be drawn, false otherwise.
	 */
	public  void setVisible(boolean visible);

	
	public  boolean isExpandable();
	public  boolean isShrinkable();

	public  Spatial getSpatial();
	
	/**
	 * Called whenever the mouse moves over this widget
	 * @param x The x position of the mouse, in local coordinates
	 * @param y The y position of the mouse, in local coordinates
	 * @return TODO
	 */
	public boolean mouseMove(float x, float y);
	
	public void setMinSize(Dimension dim);
	
	/**
	 * Called when the mouse moves off of this widget, after having been on
	 */
	public void mouseOff();
	
	/**
	 * Called when a mouse button is pressed or released while the mouse is over this widget. 
	 * @param pressed Whether the mouse button is pressed or released.
	 * @param button Which mouse button was pressed (0 == left, 1 = right, 2 = middle)
	 * @param x The x position, relative to this widget.
	 * @param y The y position, relative to this widget.
	 * @return True if the mouse press was caught by the widget, false if it should pass through and continue to hit other widgets. Returning false does not mean this widget is ignoring the mouse press, it may continue to react.
	 */
	public boolean mousePress(boolean pressed, int button,float x, float y);
	public String getToolTip();
	public void setToolTip(String toolTip);
	public void setShowToolTip(boolean showToolTip);
	public boolean showToolTip();
	public void setTooltipWidget(IToolTip toolTipWidget);
	public IToolTip getToolTipWidget();
}